import 'package:flutter/material.dart';

import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yt_devops/styles/styles.dart';

class BottomBars extends StatefulWidget {
  final int index;

  final void Function(int)? onTap;

  final List<BarItemImage> barImages;

  const BottomBars(
      {super.key, required this.index, this.onTap, this.barImages = const []});

  @override
  State<BottomBars> createState() => _BottomBarsState();
}

class _BottomBarsState extends State<BottomBars> {
  @override
  Widget build(BuildContext context) {
    return BottomNavigationBar(
      type: BottomNavigationBarType.fixed,
      currentIndex: widget.index,
      onTap: widget.onTap,
      selectedItemColor: Colour.primaryColor,
      unselectedItemColor: const Color(0xFFA4A7B5),
      items: widget.barImages
          .map(
            (e) => BottomNavigationBarItem(
              label: e.label,
              icon: Image.asset(
                e.activeImageUrl,
                width: 24.w,
                height: 24.w,

                color: const Color(0xFFC5CCD6),
              ),
              activeIcon: Image.asset(
                e.activeImageUrl,
                width: 24.w,
                height: 24.w,
                color: Colour.primaryColor,
              ),
            ),
          )
          .toList(),
    );
  }
}

class BarItemImage {
  final String imageUrl;
  final String activeImageUrl;
  final String label;

  const BarItemImage(
      {required this.label,
      required this.imageUrl,
      required this.activeImageUrl});
}
